﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;

public class ImageObject : ImgTxtObjectBase
{
    /// <summary>
    /// 图片
    /// </summary>
    [SerializeField]
    private Image m_uiImg;

    /// <summary>
    /// 字符串中的第几个索引
    /// </summary>
    [HideInInspector]
    public int Index;

    /// <summary>
    /// 表情名称
    /// </summary>
    [HideInInspector]
    public string Name
    {
        set
        {
            if (m_uiImg != null)
            {
                Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>("Assets/7.EmojiTextDemo/Texture/" + value + ".jpg");
                if(sprite != null)
                    m_uiImg.sprite = sprite;
            }
        }
    }

    /// <summary>
    /// 大小
    /// </summary>
    [HideInInspector]
    public Vector2 Size
    {
        set
        {
            RectTransform rect = transform as RectTransform;
            rect.sizeDelta = value;
        }
    }
}
